#ifndef CHATBUBBLE_H
#define CHATBUBBLE_H
class ChatBubble;
#include <QWidget>
#include <QDateTime>
#include <QVBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QPainterPath>
#include <QDebug>
#include <QPushButton>
#include "chatbubbleandhead.h"
#include "chat.h"


//struct Friend{
//    int id;
//    QString name, ip, job;
//    void show(){
//        qDebug() << id << " " << name << " " << ip << " " << job;;
//    }
//};

//struct Group{
//    int id;
//    QString name, memberlist, category;
//    void show(){
//        qDebug() << id << " " << name << " " << memberlist << " " << category;
//    }
//};

//struct Message{
//    int id, tid, rid;
//    QString msg;
//    QDateTime time;
//    void show(){
//        qDebug() << id << " " << tid << " " << rid << " " << msg << " " << time.toString("yyyy-MM-dd hh:mm:ss");
//    }
//};
class ChatBubble : public QWidget
{
    Q_OBJECT
    QColor color;
    bool isSender;
    QMarginsF mg;


    void paintEvent(QPaintEvent *event) override;

public:
    explicit ChatBubble(bool isSender, ChatWidget* prt, QWidget *parent = nullptr);
    QLabel* txt;
    void set_txt(QString send_txt);
    void set_file(const QString& fileName,const QByteArray& info,const int& sz);
    void set_picture(QPixmap picture);


    bool eventFilter(QObject *obj, QEvent *event);//事件过滤
    QPushButton* acceptButton;



private slots:

    void downloadFile();

signals:
    void ser_downloadFile(const QString& fileName,const QByteArray& info,const int& sz);

private:
    ChatWidget*  prt;
    QByteArray file_info;
    int r_sz;

};

#endif // CHATBUBBLE_H
